
# 定义任务
from celery_tasks.sms.yuntongxun.ccp_sms import CPP
from . import constants
from celery_tasks.main import celery_app
# 使用装饰器装饰异步任务，保证celery识别异步任务
@celery_app.task(name="send_sms_code")
def send_sms_code(mobile,sms_code):
    """
    发送短信验证码的异步任务
    :param mobile: 手机号
    :param sms_code: 短信验证码
    :return: 异步发送短信验证码到用户手机，0：成功，-1:失败
    """
    send_ret = CPP().sendTemplateSMS(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60],
                                     constants.SEND_SMS_TEMPLATE_ID)
    print("send_ret=", send_ret)
    return send_ret




